import Vue from 'vue'
import Router from 'vue-router'
import Hello from '@/components/Hello'
import Foo from '@/components/Foo'
import FooDefault from '@/components/FooDefault'
import FooKid1 from '@/components/FooKid1'
import FooKid2 from '@/components/FooKid2'
import Bar from '@/components/Bar'

Vue.use(Router)

const router = new Router({
   routes: [
    {
      path: '/',
      name: 'Hello',
      component: Hello,
      meta:1
    },{
      path: '/foo',
      name:'Foo',
      component: Foo,
      meta:2,
      children:[{
        path:'/',
        meta:2.1,
        component: FooDefault
      },{
        path:'fooKid1',
        meta:2.2,
        component: FooKid1
      },{
        path:'fooKid2',
        meta:2.3,
        component: FooKid2
      }]
    },{
      path: '/bar',
      name:'Bar',
      component: Bar,
      meta:3
    }
  ]
})

router.beforeEach((to, from, next) => {
  // console.log(from.meta);
  next();
})

export default router;
